﻿@page "/autocomplete"
@using NorthwindBlazor.Data
@using NorthwindBlazor.Models.Northwind
@inject NorthwindContext dbContext

<RadzenExample Name="AutoComplete">
<div class="row">
    <div class="col-md-6">
        <h3>AutoComplete</h3>
        <RadzenAutoComplete FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" Data="@customers" TextProperty="CompanyName" Style="margin-bottom: 20px" Change="@(args => Change(args, "AutoComplete"))" />
        <br />
        <h3>AutoComplete with placeholder</h3>
        <RadzenAutoComplete Placeholder="Select..." Data="@customers" TextProperty="CompanyName" Change="@(args => Change(args, "AutoComplete with placeholder"))" Style="margin-bottom: 20px" />
        <br />
        <h3>Disabled AutoComplete</h3>
        <RadzenAutoComplete Disabled="true" Data="@customers" TextProperty="CompanyName" Change="@(args => Change(args, "AutoComplete with placeholder"))" Style="margin-bottom: 20px" />
        <br />
    </div>
    <div class="col-md-6">
        <h3>Events</h3>
        <RadzenCard style="overflow: auto;height:500px;">
            @foreach (var e in events.OrderByDescending(i => i.Key))
            {
                @e.Value
                <br />
            }
        </RadzenCard>
    </div>
</div>
</RadzenExample>

@code {
    IEnumerable<Customer> customers;

    protected override async Task OnInitializedAsync()
    {
        customers = await Task.FromResult(dbContext.Customers);
    }

    Dictionary<DateTime, string> events = new Dictionary<DateTime, string>();

    void Change(object value, string name)
    {
        events.Add(DateTime.Now, $"{name} value changed to {value}");
        StateHasChanged();
    }
}
